import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";
import Login from "@/pages/login/Login.vue";

//一级菜单
const routes: RouteRecordRaw[] = [
  {
    path: "/",
    redirect: "/login",
  },
  {
    path: "/login",
    component: Login,
    meta: { title: "登陆页", meta: { transitionName: "fade" } },
  },
  {
    path: "/eidtor",
    name: "eidtor",
    meta: { title: "编辑器", meta: { transitionName: "fade" } },
    component: () => import("@/pages/editor/Eidtor.vue"),
  },
  // 404 page must be placed at the end !!!,vue3已弃用 * 通配符
  // {
  //     path: '*',
  //     redirect: '/404',
  //     hidden: true,
  // }
  {
    path: "/:pathMatch(.*)",
    name: "404",
    component: () => import("@/pages/404/404.vue"), //路由懒加载，异步导入组件
  },
];

export const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

router.beforeEach((to, from, next) => {
  next(); //表示当前导航守卫放行
});
